module.exports = function(e) {
	// 公用模块用法请参考 https://uniapp.dcloud.io/uniCloud/cf-common
	return e
}
const {
	mainSpaceId
} = require('config-space')
/**
 * @param {Object} key
 * @param {Object} del 是否删除
 * @param {Object} catchDuration
 * @param {Object} spaceId
 */
async function redisGet(key,del,catchDuration,spaceId) {
	if(!spaceId){
		spaceId=mainSpaceId
	}
	const redisCloud = uniCloud.init({
	  provider: 'tencent',
	  spaceId: spaceId
	}); 
	let callFunctionResult = await redisCloud.callFunction({
	    name: "catering_redis",
	    data:{
	        path: '/redis/get',
	        data:{
				key:key
			}
	    }
	})
	let result=callFunctionResult.result
	return result
}

async function redisSet(key,setData,catchDuration,spaceId) {
	if(!spaceId){
		spaceId=mainSpaceId
	}
	const redisCloud = uniCloud.init({
	  provider: 'tencent',
	  spaceId: spaceId
	});  
	let callFunctionResult = await redisCloud.callFunction({
	    name: "catering_redis",
	    data:{
	        path: '/redis/set',
	        data:{
				key:key,
				data:setData
			}
	    }
	})
}

async function redisDelete(key,spaceId) {
	if(!spaceId){
		spaceId=mainSpaceId
	}
	const redisCloud = uniCloud.init({
	  provider: 'tencent',
	  spaceId: spaceId
	});  
	let callFunctionResult = await redisCloud.callFunction({
	    name: "catering_redis",
	    data:{
	        path: '/redis/delete',
	        data:{
				key:key
			}
	    }
	})
}

module.exports = {
	redisGet,
	redisSet,
	redisDelete
}